package com.继承.基础;
class A{
    int a = 1;
    int b = 2;
    A(){

    }
    A(int a ,int b){
        this.a =a;
        this.b = b;
    }

    void fun1(){
        System.out.println("A中的fun1");
    }

    static void fun3(){
        System.out.println("A中的静态方法fun3");
    }
}
class B extends A{
    int c = 3;
    void fun2(){
        System.out.println("B中的fun2");
    }
    public static void main(String[] args) {
        B b1 = new B();
        //子类和父类成员变量不同名
        System.out.println(b1.a);
        System.out.println(b1.b);
        System.out.println(b1.c);

        //子类和父类成员方法不同名
        b1.fun1();
        b1.fun2();

        b1.fun3();
    }
}
class C extends A{
    int a = 8;
    int c =12;

    void fun1() {
        System.out.println("c中的fun1");
    }

    public static void main(String[] args) {
        C c1 = new C();
        //子类和父类成员变量同名
        System.out.println(c1.a);
        System.out.println(c1.b);
        System.out.println(c1.c);

//        子类和父类成员方法同名
        c1.fun1();//就近原则
    }
}

